package org.NooLab.glue.net;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.UUID;

import org.apache.ftpserver.ftplet.DataConnection;

public class DataSlot {
	
	/** this is created by the ftpserver  */
	public UUID sessionID;
	
	/** this is created in a synchronized manner within the accepting thread, we use it 
	 * in order to be able to sort the messages according their incoming order, if this
	 * would be necessary
	 */
	public long transmissionID;
	
	public int serverPort;
	public int clientPort;
	public String clientAddr;
	
	
	public DataConnection dataConnection ;
	public ByteArrayOutputStream byteOutStream ;
	
	byte[] byteArray ;
	
	public DataSlot(){
		byteOutStream = new ByteArrayOutputStream () ;	
	}

	
	public void closeStream(){
	
		try {
			
			if (byteOutStream!=null){
				
				byteOutStream.flush();
				
				byteArray = byteOutStream.toByteArray();
				
				byteOutStream.close();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public DataConnection getDataConnection() {
		return dataConnection;
	}

	public void setDataConnection(DataConnection dataConnection) {
		this.dataConnection = dataConnection;
	}


	public byte[] getByteArray() {
		return byteArray;
	}


	public UUID getSessionID() {
		return sessionID;
	}


	public long getTransmissionID() {
		return transmissionID;
	}
	
	
	
	
}
